Chinese remainder theorem

The Chinese remainder theorem is a result about congruences in number theory and its generalizations in abstract algebra.

Contents

Theorem statement

The original form of the theorem, contained in a third-century AD book Sun Zi suanjing (孙子算经 The Mathematical Classic by Sun Zi) by Chinese mathematician Sun Tzu and later republished in a 1247 book by Qin Jiushao, the Shushu Jiuzhang (數書九章 Mathematical Treatise in Nine Sections) is a statement about simultaneous congruences (see modular arithmetic).

Suppose n1, n2, …, nk are positive integers which are pairwise coprime. Then, for any given integers a1,a2, …, ak, there exists an integer x solving the system of simultaneous congruences

\begin{align}
 x &\equiv a_1 \pmod{n_1} \\
 x &\equiv a_2 \pmod{n_2} \\
   &\vdots \\
 x &\equiv a_k \pmod{n_k}
\end{align}

Furthermore, all solutions x to this system are congruent modulo the product N = n1n2nk.

Hence x \equiv y \pmod{n_i} for all 1\leq i \leq k, if and only if x \equiv y \pmod{N}.

Sometimes, the simultaneous congruences can be solved even if the ni's are not pairwise coprime. A solution x exists if and only if:

a_i \equiv a_j \pmod{\gcd(n_i,n_j)} \qquad \mbox{for all }i\mbox{ and }j . \,\!

All solutions x are then congruent modulo the least common multiple of the ni.

An alternative method for solving similar systems of equations was described by Aryabhata (6th century; see Kak 1986). Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century), and appear in Fibonacci's Liber Abaci (1202).

A constructive algorithm to find the solution

The following algorithm only applies if the n_i's are pairwise coprime. (For simultaneous congruences when the moduli are not pairwise coprime, the method of successive substitution can often yield solutions.)

Suppose, as above, that a solution is required for the system of congruences:

x \equiv a_i \pmod{n_i} \quad\mathrm{for}\; i = 1, \ldots, k.

Again, to begin, the product  N=n_1n_2\ldots n_k is defined. Then a solution x can be found as follows.

For each i the integers n_i and N/n_i are coprime. Using the extended Euclidean algorithm we can find integers r_i and s_i such that r_in_i + s_iN/n_i = 1. Then, choosing the label e_i=s_iN/n_i, the above expression becomes:

 r_i n_i + e_i = 1 \,\!

Consider e_i. The above equation guarantees that its remainder, when divided by n_i, must be 1. On the other hand, since it is formed as s_iN/n_i, the presence of N guarantees that it's evenly divisible by any n_j so long as j\ne i.

e_i \equiv 1 \pmod{n_i} \quad \mathrm{and} \quad e_i \equiv 0 \pmod{n_j} \quad \mathrm{for} ~ i \ne j

Because of this, combined with the multiplication rules allowed in congruences, one solution to the system of simultaneous congruences is:

 x = \sum_{i=1}^k a_i e_i.\!

For example, consider the problem of finding an integer x such that

x \equiv 2 \pmod{3}, \,\!
x \equiv 3 \pmod{4}, \,\!
x \equiv 1 \pmod{5}. \,\!

Using the extended Euclidean algorithm for x modulo 3 and 20 [4×5], we find (−13) × 3 + 2 × 20 = 1, i.e. e1 = 40. For x modulo 4 and 15 [3×5], we get (−11) × 4 + 3 × 15 = 1, i.e. e2 = 45. Finally, for x modulo 5 and 12 [3×4], we get 5 × 5 + (−2) × 12 = 1, i.e. e3 = −24. A solution x is therefore 2 × 40 + 3 × 45 + 1 × (−24) = 191. All other solutions are congruent to 191 modulo 60, [3 × 4 × 5 = 60] which means that they are all congruent to 11 modulo 60.

NOTE: There are multiple implementations of the extended Euclidean algorithm which will yield different sets of e_1, e_2, and e_3. These sets however will produce the same solution i.e. 11 modulo 60.

Statement for principal ideal domains

For a principal ideal domain R the Chinese remainder theorem takes the following form: If u1, ..., uk are elements of R which are pairwise coprime, and u denotes the product u1...uk, then the quotient ring R/uR and the product ring R/u1R× ... × R/ukR are isomorphic via the isomorphism

f�: R/uR \rightarrow R/u_1R \times \cdots \times
R/u_k R

such that

f(x +uR) = (x + u_1R, \ldots , x +u_kR) \quad\mbox{ for every } x\in R.

This isomorphism is unique; the inverse isomorphism can be constructed as follows. For each i, the elements ui and u/ui are coprime, and therefore there exist elements r and s in R with

r u_i + s u/u_i = 1. \,\!

Set ei = s u/ui. Then the inverse of f is the map

g�: R/u_1R \times \cdots \times R/u_kR
\rightarrow R/uR

such that

g(a_1+u_1R,\ldots ,a_k+u_kR)=
\left( \sum_{i=1}^k a_i e_i \right) + uR \quad\mbox{ for all }a_1,\ldots,a_k\in R.

Note that this statement is a straightforward generalization of the above theorem about integer congruences: the ring Z of integers is a principal ideal domain, the surjectivity of the map f shows that every system of congruences of the form

x \equiv a_i \pmod{u_i} \quad\mathrm{for}\; i = 1, \ldots, k

can be solved for x, and the injectivity of the map f shows that all the solutions x are congruent modulo u.

Statement for general rings

The general form of the Chinese remainder theorem, which implies all the statements given above, can be formulated for commutative rings and ideals. If R is a commutative ring and I1, ..., Ik are ideals of R which are pairwise coprime (meaning that Ii + Ij = R whenever ij), then the product I of these ideals is equal to their intersection, and the quotient ring R/I is isomorphic to the product ring R/I1 x R/I2 x ... x R/Ik via the isomorphism

f�: R/I \rightarrow R/I_1 \times \cdots \times R/I_k

such that

f(x + I) = (x +I_1, \ldots , x+I_k) \quad\mbox{ for all } x\in R.

Applications

P^{(k)}(\lambda_j)=a_{j,k}\quad\forall 1\leq j\leq r\ , 0\leq k<\nu_j.
Introducing the polynomials
\textstyle A_j(x):=\sum_{k=0}^{\nu_j-1}\frac{a_{j,k}}{k!}(x-\lambda_j)^k,
the problem may be equivalently reformulated as a system of r\ simultaneous congruences:
P(x)\equiv A_j(x)\pmod{(x-\lambda_j)^{\nu_j}},\quad\forall 1\leq j\leq r\ .
By the Chinese remainder theorem in the principal ideal domain \textstyle\C[x], there is a unique such polynomial \textstyle P(x) with degree \textstyle\deg(P)<n:=\sum_j\nu_j. A direct construction, in analogy with the above proof for the integer number case, can be performed as follows. Define the polynomials \textstyle Q:=\prod_{i=1}^{r}(x-\lambda_i)^{\nu_i} and \textstyle Q_j:=\frac{Q}{(x-\lambda_j)^{\nu_j}}. The partial fraction decomposition of \textstyle \frac{1}{Q} gives r polynomials \textstyle S_j with degrees \textstyle\deg(S_j)<\nu_j such that
\frac{1}{Q}=\sum_{i=1}^{r}\frac{S_i}{(x-\lambda_i)^{\nu_i}},
so that \textstyle 1=\sum_{i=1}^{r}S_i Q_i. Then a solution of the simultaneous congruence system is given by the polynomial
 \sum_{i=1}^{r} A_i S_i Q_i = A_j + \sum_{i=1}^{r}(A_i-A_j) S_i Q_i\equiv A_j\pmod{(x-\lambda_j)^{\nu_j}}\quad\forall 1\leq j\leq r\  ;
and the minimal degree solution is this one reduced modulo \textstyle Q, that is the unique with degree less than n.
Proof using the Chinese Remainder Theorem: First, assume that k is a field (otherwise, replace the integral domain k by its quotient field, and nothing will change). We can linearly extend the monoid homomorphisms f_i:M\to k to k-algebra homomorphisms F_i:k\left[M\right]\to k, where k\left[M\right] is the monoid ring of M over k. Then, the condition \sum_{i\in I}\alpha_i f_i=0 yields \sum_{i\in I}\alpha_i F_i=0 by linearity. Now, we notice that if i\neq j are two elements of the index set I, then the two k-linear maps F_i:k\left[M\right]\to k and F_j:k\left[M\right]\to k are not proportional to each other (because if they were, then f_i and f_j would also be proportional to each other, and thus equal to each other since f_i\left(1\right)=1=f_j\left(1\right) (since f_i and f_j are monoid homomorphisms), contradicting the assumption that they be distinct). Hence, their kernels \mathrm{Ker} F_i and \mathrm{Ker} F_j are distinct. Now, \mathrm{Ker} F_i is a maximal ideal of k\left[M\right] for every i\in I (since k\left[M\right] / \mathrm{Ker} F_i\cong F_i\left(k\left[M\right]\right)=k is a field), and the ideals \mathrm{Ker} F_i and \mathrm{Ker} F_j are coprime whenever i\neq j (since they are distinct and maximal). The Chinese Remainder Theorem (for general rings) thus yields that the map
\phi: k\left[M\right] /  K\to \prod_{i\in I}k\left[M\right] /  \mathrm{Ker} F_i
given by
\phi\left(x+K\right)=\left(x+\mathrm{Ker} F_i\right)_{i\in I} for all x\in k\left[M\right]
is an isomorphism, where K=\prod_{i\in I}\mathrm{Ker} F_i=\bigcap_{i\in I}\mathrm{Ker} F_i. Consequently, the map
\Phi: k\left[M\right]\to \prod_{i\in I}k\left[M\right] /  \mathrm{Ker} F_i
given by
\Phi\left(x\right)=\left(x+\mathrm{Ker} F_i\right)_{i\in I} for all x\in k\left[M\right]
is surjective. Under the isomorphisms k\left[M\right] /  \mathrm{Ker} F_i\to F_i\left(k\left[M\right]\right)=k, this map \Phi corresponds to the map
\psi: k\left[M\right]\to \prod_{i\in I}k
given by
x\mapsto\left(F_i\left(x\right)\right)_{i\in I} for every x\in k\left[M\right].
Now, \sum_{i\in I}\alpha_i F_i=0 yields \sum_{i\in I}\alpha_i u_i=0 for every vector \left(u_i\right)_{i\in I} in the image of the map \psi. Since \psi is surjective, this means that \sum_{i\in I}\alpha_i u_i=0 for every vector \left(u_i\right)_{i\in I}\in \prod_{i\in I}k. Consequently, \left(\alpha_i\right)_{i\in I}=\left(0\right)_{i\in I}, qed.

Non-commutative case: a counter-example

The Chinese remainder theorem does not hold in the non-commutative case. Consider the ring R of non-commutative real polynomials in x and y. Let I be the principal two-sided ideal generated by x and J the principal two-sided ideal generated by xy+1. Then I+J=R but I\cap J \neq IJ.

Proof

Observe that I is formed by all polynomials with an x in every term and that every polynomial in J vanishes under the substitution y=-1/x. Consider the polynomial p=(xy+1)x. Clearly p\in I\cap J. Define a term in R as an element of the multiplicative monoid of R generated by x and y. Define the degree of a term as the usual degree of the term after the substitution y=x. On the other hand, suppose q\in J. Observe that a term in q of maximum degree depends on y otherwise q under the substitution y=-1/x can not vanish. The same happens then for an element q\in IJ. Observe that the last y, from left to right, in a term of maximum degree in an element of IJ is preceded by more than one x. (We are counting here all the preceding xs. e.g. in x^2yxyx^5 the last y is preceded by 3 xs.) This proves that (xy+1)x\notin IJ since that last y in a term of maximum degree (xyx) is preceded by only one x. Hence I\cap J\neq IJ.

On the other hand, it is true in general that I+J = R implies I \cap J = IJ + JI. To see this, note that  I \cap J = (I \cap J) (I+J) \subset IJ + JI, while the opposite inclusion is obvious. Also, we have in general that, provided I_1, \ldots, I_m are pairwise coprime two-sided ideals in R, the natural map

R / (I_1 \cap I_2 \cap \ldots \cap I_m) \rightarrow R/I_1 \oplus R/I_2 \oplus \cdots \oplus R/I_m

is an isomorphism. Note that I_1 \cap I_2 \cap \ldots \cap I_m can be replaced by a sum over all orderings of I_1, \ldots, I_m of their product (or just a sum over enough orderings, using inductively that I \cap J = IJ + JI for coprime ideals I, J).

See also

References

External links